<?php

namespace App\Models\Order;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ContractPreviewExtend extends Model
{
    protected $table = 'contract_preview_extend';
    public $timestamps = false;
    protected $primaryKey = 'id';
    protected $guarded = ['_token'];
    //订单预览合同
    public static function dopostadd($data = [])
    {
        $res = ["code"=>"001","msg"=>""];
        if(empty($data["serial_number"])){
            $res["msg"] = "合同序号不能为空";
            return $res;
        }
        if(empty($data["source_id"])){
            $res["msg"] = "单据来源不能为空";
            return $res;
        }
        $create_id = self::create($data)->id;
        if($create_id > 0){
            $res["msg"] = "新增成功";
            $res["code"] = "000";
            $res["data"] = $create_id;
            return $res;
        }else{
            $res["msg"] = "新增失败";
            return $res;
        }
    }
}
